﻿	                <div class="tabbable">
		                <ul class="nav nav-tabs" id="myTab">
			                <li class="active">
				                <a data-toggle="tab" href="#tab1">
					                后台菜单
				                </a>
			                </li>

			                <li class="tab-red">
				                <a data-toggle="tab" href="#tab2">
					                增加
				                </a>
			                </li>
		                </ul>

		                <div class="tab-content">
			                <div id="tab1" class="tab-pane active">
				                <div role="grid" id="editabledatatable_wrapper" class="dataTables_wrapper form-inline no-footer">
									<table class="table table-striped table-hover table-bordered dataTable no-footer" id="editabledatatable" aria-describedby="editabledatatable_info">
										<thead class="bordered-bottom-1 bordered-orange">
										<tr>
											<th class="text-center">ID</th>
											<th class="text-center">名称</th>
											<th class="text-center">图标</th>
											<th class="text-center">上级菜单</th>
											<th class="text-center">URL</th>
											<th class="text-center">排序</th>
											<th class="text-center">操作</th>
										</tr>
										</thead>
										<tbody>
										<?php
										if( empty( $table_menu ) ):
										?>
										<tr>
											<td colspan="7" class="text-center">该层级无菜单</td>
										</tr>
										<?php endif; ?>
										<?php foreach( $table_menu as $m ):?>
										<tr>
											<td class="text-center"><?=$m->id;?></td>
											<td class="text-center"><a href="<?=site_url( 'navi/menu') . '/' . $m->id;?>"><?=$m->name;?></a></td>
											<td class="text-center"><i class="fa <?=$m->icon;?>"></i></td>
											<td class="text-center"><?=$parent_name;?></td>
											<td class="text-center"><?=$m->url;?></td>
											<td class="text-center"><?=$m->order;?></td>
											<td class="text-center" style="width: 200px;">
												<button class="btn btn-info btn-xs edit" onclick="show_modal( 'modal', '<?=site_url( 'navi/edit_menu') . '/' .$m->id;?>')"><i class="fa fa-pencil"></i> 编辑</button>
												<button class="btn btn-danger btn-xs delete" onclick="bb_confirm( '确定要删除【<?=$m->name;?>】？', '<?=site_url('navi/do_del_menu'). '/' .$m->id;?>')"><i class="fa fa-trash-o"></i> 删除</button>
											</td>
										</tr>
										<?php endforeach; ?>
										</tbody>
									</table>
									<?php if( $parent_name != '无' ): ?>
									<div class="text-right">
										<button class="btn btn-block btn-palegreen" onclick="history.back( -1 )">返回上一级</button>
									</div>
									<?php endif; ?>
								</div>
			                </div>

			                <div id="tab2" class="tab-pane">
								<form class="form">
									<div class="form-group clearfix form-bordered">
										<label class="control-label col-md-1">菜单名称</label>
										<div class="col-md-11">
											<div class="form-group">
												<input type="text" class="form-control" name="name" id="name" placeholder="菜单名称">
											</div>
										</div>
									</div>
									<div class="form-group clearfix form-bordered">
										<label class="control-label col-md-1">上级菜单</label>
										<select class="" name="parent_id" id="parent_id">
											<option value="0">作为顶级</option>
										<?php foreach( $top_menu as $t ):?>
											<option value="<?=$t->id;?>"><?=$t->name;?></option>
										<?php endforeach; ?>
										</select>
									</div>
									<div class="form-group clearfix form-bordered">
										<label class="control-label col-md-1">图标</label>

										<div class="col-md-11">
											<div class="form-group">
												<input type="text" class="form-control" name="icon" id="icon" placeholder="Font Awesome图标">
											</div>
										</div>
									</div>
									<div class="form-group clearfix form-bordered">
										<label class="control-label col-md-1">URL</label>

										<div class="col-md-11">
											<div class="form-group">
												<input type="text" class="form-control" name="url" id="url" placeholder="路径（控制器/方法）">
											</div>
										</div>
									</div>

									<div class="form-group clearfix form-bordered">
										<label class="control-label col-md-1">排序</label>

										<div class="col-md-11">
											<div class="form-group">
												<input type="number" class="form-control" name="order" id="order" placeholder="排序（数字越小越靠前）">
											</div>
										</div>
									</div>

									<div class="form-group text-right clearfix">
										<button class="btn btn-success" type="button" id="add_menu"><i class="fa fa-plus"></i>添加</button>
										<button type="reset" class="btn btn-default" onclick="window.location.reload()">取消</button>
									</div>
								</form>
				                <div class="clearfix"></div>
			                </div>
		                </div>
	                </div>
<script>
$('#add_menu').click(function(){
	ajax_post(
		'<?=site_url( 'navi/do_add_menu' );?>',
		{
			name:$("#name").val(),
			parent_id:$("#parent_id").val(),
			icon:$("#icon").val(),
			url:$("#url").val(),
			order:$("#order").val(),
		}
	);}
)
	
</script>